#include "Player.h"
#include <gtest\gtest.h>

using namespace sf;
/*
TEST(Player, characterInterpretEventAndMove)
{
	;
	Player p1(Vector2f(20, 20), 50, Vector2f(10, 10), TANK1);
	
	float i = p1.getPosition().y;    //test haut
	p1.characterInterpretEvent(UP_PRESS);
	p1.move();
	p1.characterInterpretEvent(UP_RELEASE);
	p1.move();
	EXPECT_EQ(p1.getPosition().y, i- p1.getSpeed().y);
	EXPECT_EQ(p1.getPosition(), p1.getSprite().getPosition());
	
	i = p1.getPosition().y;   //test bas
	p1.characterInterpretEvent(DOWN_PRESS);
	p1.move();
	p1.characterInterpretEvent(DOWN_RELEASE);
	p1.move();
	EXPECT_EQ(p1.getPosition().y, i + p1.getSpeed().y);
	EXPECT_EQ(p1.getPosition(), p1.getSprite().getPosition());
	
	i = p1.getPosition().x;   //test gauche
	p1.characterInterpretEvent(LEFT_PRESS);
	p1.move();
	p1.characterInterpretEvent(LEFT_RELEASE);
	p1.move();
	EXPECT_EQ(p1.getPosition().x, i - p1.getSpeed().x);
	EXPECT_EQ(p1.getPosition(), p1.getSprite().getPosition());
	
	i = p1.getPosition().x;  //test droite
	p1.characterInterpretEvent(RIGHT_PRESS);
	p1.move();
	p1.characterInterpretEvent(RIGHT_RELEASE);
	p1.move();
	EXPECT_EQ(p1.getPosition().x, i + p1.getSpeed().x);
	EXPECT_EQ(p1.getPosition(), p1.getSprite().getPosition());



	Vector2f j = p1.getPosition();  //test Haut droite
	p1.characterInterpretEvent(UP_PRESS);
	p1.characterInterpretEvent(RIGHT_PRESS);
	p1.move();
	p1.characterInterpretEvent(UP_RELEASE);
	p1.characterInterpretEvent(RIGHT_RELEASE);
	p1.move();

	EXPECT_EQ(p1.getPosition().x, j.x + p1.getSpeed().x);
	EXPECT_EQ(p1.getPosition().y, j.y- p1.getSpeed().y);
	EXPECT_EQ(p1.getPosition(), p1.getSprite().getPosition());

	j = p1.getPosition();  //test Haut Gauche
	p1.characterInterpretEvent(UP_PRESS);
	p1.characterInterpretEvent(LEFT_PRESS);
	p1.move();
	p1.characterInterpretEvent(UP_RELEASE);
	p1.characterInterpretEvent(LEFT_RELEASE);
	p1.move();

	EXPECT_EQ(p1.getPosition().x, j.x - p1.getSpeed().x);
	EXPECT_EQ(p1.getPosition().y, j.y - p1.getSpeed().y);
	EXPECT_EQ(p1.getPosition(), p1.getSprite().getPosition());

	j = p1.getPosition();  //test bas droite
	p1.characterInterpretEvent(DOWN_PRESS);
	p1.characterInterpretEvent(RIGHT_PRESS);
	p1.move();
	p1.characterInterpretEvent(DOWN_RELEASE);
	p1.characterInterpretEvent(RIGHT_RELEASE);
	p1.move();

	EXPECT_EQ(p1.getPosition().x, j.x + p1.getSpeed().x);
	EXPECT_EQ(p1.getPosition().y, j.y + p1.getSpeed().y);
	EXPECT_EQ(p1.getPosition(), p1.getSprite().getPosition());

	j = p1.getPosition();  //test bas gauche
	p1.characterInterpretEvent(DOWN_PRESS);
	p1.characterInterpretEvent(LEFT_PRESS);
	p1.move();
	p1.characterInterpretEvent(DOWN_RELEASE);
	p1.characterInterpretEvent(LEFT_RELEASE);
	p1.move();

	EXPECT_EQ(p1.getPosition().x, j.x - p1.getSpeed().x);
	EXPECT_EQ(p1.getPosition().y, j.y + p1.getSpeed().y);
	EXPECT_EQ(p1.getPosition(), p1.getSprite().getPosition());



	j = p1.getPosition();  //test droite gauche
	p1.characterInterpretEvent(LEFT_PRESS);
	p1.characterInterpretEvent(RIGHT_PRESS);
	p1.move();
	p1.characterInterpretEvent(LEFT_RELEASE);
	p1.characterInterpretEvent(RIGHT_RELEASE);
	p1.move();

	EXPECT_EQ(p1.getPosition(), j );
	EXPECT_EQ(p1.getPosition(), p1.getSprite().getPosition());
	

	j = p1.getPosition();  //test haut bas
	p1.characterInterpretEvent(UP_PRESS);
	p1.characterInterpretEvent(DOWN_PRESS);
	p1.move();
	p1.characterInterpretEvent(UP_RELEASE);
	p1.characterInterpretEvent(DOWN_RELEASE);
	p1.move();

	EXPECT_EQ(p1.getPosition(), j);
	EXPECT_EQ(p1.getPosition(), p1.getSprite().getPosition());


}

TEST(Player, stopAction)
{
	
	Player p1(Vector2f(20, 20), 50, Vector2f(10, 10));
	Vector2f i = p1.getPosition();
	p1.setUp(1);	
	p1.setRight(1);
	p1.stopAction();
	p1.move();
	EXPECT_EQ(p1.getPosition(), i);
	
}

TEST(Player, omniMove)
{

	Player p1(Vector2f(20, 20), 50, Vector2f(10, 10));

	float i = p1.getPosition().y;    //test haut
	p1.setUp(1);
	p1.move();
	p1.setUp(0);
	EXPECT_EQ(p1.getPosition().y, i - p1.getSpeed().y);
	EXPECT_EQ(p1.getPosition(), p1.getSprite().getPosition());

	i = p1.getPosition().y;   //test bas
	p1.setDown(1);
	p1.move();
	p1.setDown(0);
	EXPECT_EQ(p1.getPosition().y, i + p1.getSpeed().y);
	EXPECT_EQ(p1.getPosition(), p1.getSprite().getPosition());

	i = p1.getPosition().x;   //test gauche
	p1.setLeft(1);
	p1.move();
	p1.setLeft(0);
	EXPECT_EQ(p1.getPosition().x, i - p1.getSpeed().x);
	EXPECT_EQ(p1.getPosition(), p1.getSprite().getPosition());

	i = p1.getPosition().x;  //test droite
	p1.setRight(1);
	p1.move();
	p1.setRight(0);
	EXPECT_EQ(p1.getPosition().x, i + p1.getSpeed().x);
	EXPECT_EQ(p1.getPosition(), p1.getSprite().getPosition());



	Vector2f j = p1.getPosition();  //test Haut droite
	p1.setUp(1);
	p1.setRight(1);
	p1.move();
	p1.setRight(0);
	p1.setUp(0);

	EXPECT_EQ(p1.getPosition().x, j.x + p1.getSpeed().x);
	EXPECT_EQ(p1.getPosition().y, j.y - p1.getSpeed().y);
	EXPECT_EQ(p1.getPosition(), p1.getSprite().getPosition());

	j = p1.getPosition();  //test Haut Gauche
	p1.setUp(1);
	p1.setLeft(1);
	p1.move();
	p1.setLeft(0);
	p1.setUp(0);

	EXPECT_EQ(p1.getPosition().x, j.x - p1.getSpeed().x);
	EXPECT_EQ(p1.getPosition().y, j.y - p1.getSpeed().y);
	EXPECT_EQ(p1.getPosition(), p1.getSprite().getPosition());

	j = p1.getPosition();  //test bas droite
	p1.setDown(1);
	p1.setRight(1);
	p1.move();
	p1.setRight(0);
	p1.setDown(0);

	EXPECT_EQ(p1.getPosition().x, j.x + p1.getSpeed().x);
	EXPECT_EQ(p1.getPosition().y, j.y + p1.getSpeed().y);
	EXPECT_EQ(p1.getPosition(), p1.getSprite().getPosition());

	j = p1.getPosition();  //test bas gauche
	p1.setDown(1);
	p1.setLeft(1);
	p1.move();
	p1.setDown(0);
	p1.setLeft(0);

	EXPECT_EQ(p1.getPosition().x, j.x - p1.getSpeed().x);
	EXPECT_EQ(p1.getPosition().y, j.y + p1.getSpeed().y);
	EXPECT_EQ(p1.getPosition(), p1.getSprite().getPosition());



	j = p1.getPosition();  //test droite gauche
	p1.setRight(1);
	p1.setLeft(1);
	p1.move();
	p1.setRight(0);
	p1.setLeft(0);

	EXPECT_EQ(p1.getPosition(), j);
	EXPECT_EQ(p1.getPosition(), p1.getSprite().getPosition());


	j = p1.getPosition();  //test haut bas
	p1.setDown(1);
	p1.setUp(1);
	p1.move();
	p1.setDown(0);
	p1.setUp(0);

	EXPECT_EQ(p1.getPosition(), j);
	EXPECT_EQ(p1.getPosition(), p1.getSprite().getPosition());

}

*/